<template>
  <div class="app-container">
    <!--顶部搜索条件-->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="车牌号" prop="vehicleNo">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入检测项目"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检测方法" prop="checkMethod">
        <el-select
          v-model="queryParams.checkMethod"
          placeholder="请选择检测方法"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in dict.type.check_method"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!--表格-->
    <el-table v-loading="loading" :data="itemList" >
      <el-table-column label="检测编号" prop="itemId" align="center"/>
      <el-table-column label="检测项目" prop="itemName" align="center"/>
      <el-table-column label="检测方法" prop="checkMethod" align="center">
        <template slot-scope="scope">
          <span>
            {{ selectDictLabels(dict.type.check_method,scope.row.checkMethod) }}
          </span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listCheckItem} from "@/api/check/item";

export default {
  name: "itemIndex",
  dicts: ['check_method'],
  data(){
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemName: "",
        checkMethod: ""
      },
      showSearch: true,
      loading: false,
      itemList: [],
      total: 0
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList(){
      this.loading = true
      listCheckItem(this.addDateTimeRange(this.queryParams)).then(response => {
        this.itemList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    handleQuery(){
      this.queryParams.pageNum = 1
      this.getList()
    },
    resetQuery(){

    }
  }
}
</script>

<style scoped>

</style>
